package com.agents.builder.common.ai.strategy.impl;

import com.agents.builder.common.ai.enums.LlmProvider;
import com.agents.builder.common.ai.strategy.EmbeddingModelBuilder;
import com.agents.builder.common.ai.strategy.common.BaseEmbeddingModelBuilder;
import org.springframework.ai.document.MetadataMode;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.openai.OpenAiEmbeddingModel;
import org.springframework.ai.openai.OpenAiEmbeddingOptions;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class QwenEmbeddingModelBuilder extends BaseEmbeddingModelBuilder {



    private static final String DEFAULT_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode";


    public EmbeddingModel getEmbeddingModel(String apiKey, String baseUrl,String modelName) {
        return new OpenAiEmbeddingModel(new OpenAiApi(Optional.ofNullable(baseUrl).orElse(DEFAULT_BASE_URL), apiKey), MetadataMode.EMBED, OpenAiEmbeddingOptions.builder().dimensions(milvusVectorStoreProperties.getEmbeddingDimension()).model(modelName).build());
    }

    @Override
    public LlmProvider provider() {
        return LlmProvider.QWEN;
    }
}
